﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using SAR.Pages;

namespace SAR
{
	public partial class DianMuBiaoPageControl
	{
        public DianMuBiaoPageControl()
		{
			this.InitializeComponent();
            if (currentStp == 0)
            {
                this.preStepButton.SARIsEnabled = false;
            }

            //初始化化页面流程序列

            pageCtrLists[0] = "DianMuBiaoPingGu0.xaml";
            pageCtrLists[1] = "DianMuBiaoPingGu0.xaml";
            pageCtrLists[2] = "DianMuBiaoPingGu2.xaml";
            maxStepNum = 2;

            //调用父类
            this.DoPage.ContentRendered += new EventHandler(DoPage_ContentRendered);
		}
       
        //属性，页面路径数组，必须初始化！
        public string[] pageCtrLists = new string[100];

        private int currentStp = 0;

        //属性CurrentStep，代表当前步骤
        public int CurrentStep
        {
            get
            {
                return currentStp;
            }
            set
            {
                this.currentStp=value;

                //设置进度条
                this.overallStepBar.SARCurrentStep = currentStp;
            }
        }
        private int maxStepNum = 6;

        //属性MaxStepNum，代表流程最大步骤数

        public int MaxStepNum
        {
            get
            {
                return maxStepNum;
            }

            set
            {
                this.maxStepNum = value;
            }
        }

        private string currentPagePath;

        //属性，当前页面相对路径
        public string CurrentPagePath
        {
            get
            {
                return currentPagePath;
            }
            set
            {
                this.currentPagePath = value;
                this.DoPage.Source = new System.Uri(currentPagePath, UriKind.Relative);      
            }
        }

        //上一步点击事件
        private void preStepButton_SARPreClick(object sender, MouseButtonEventArgs e)
        {
            BasePageClass currentPage = this.DoPage.Content as BasePageClass;
            currentPage.PreClick();


            this.nextStepButton.SARIsEnabled = true;
            if (currentStp > 0)
            {
                currentStp--;
                if(currentStp == 0)
                {
                    this.preStepButton.SARIsEnabled = false;
                }
            }
            else
            {
                currentStp = 0;
                this.preStepButton.SARIsEnabled = false;
            }
            this.overallStepBar.SARCurrentStep = currentStp;

            //重新显示图片载入按钮
            Page thispage = this.DoPage.Content as Page;
            if (thispage is DianMuBiaoPingGu0)
            {
                if (currentStp == 0)
                {
                    (thispage as DianMuBiaoPingGu0).DianMubiaoPingGuShowImgBtn();
                }

            }
            
            this.DoPage.Source = new System.Uri(pageCtrLists[currentStp], UriKind.Relative);
                        
        }

        //下一步点击事件
        private void nextStepButton_SARNextClick(object sender, MouseButtonEventArgs e)
        {
            BasePageClass currentPage = this.DoPage.Content as BasePageClass;
            currentPage.NextClick();

           


            this.preStepButton.SARIsEnabled = true;
            if(currentStp >= maxStepNum - 1 )
            {
                currentStp = maxStepNum;
                this.nextStepButton.SARIsEnabled = false;
            }else
            {
                currentStp++;
            }
            this.overallStepBar.SARCurrentStep = currentStp;
            Page thispage = this.DoPage.Content as Page;
            if (thispage is DianMuBiaoPingGu0)
            {
                if (currentStp == 1)
                {
                    (thispage as DianMuBiaoPingGu0).DianMuBiaoPingGu1_Loaded();
                }

            }
            this.DoPage.Source = new System.Uri(pageCtrLists[currentStp], UriKind.Relative);

                      
                          
        }

        void DoPage_ContentRendered(object sender, EventArgs e)
        {
            //如果需要父页面
            if ((this.DoPage.Content as PageWithParent) != null)
            {
                (this.DoPage.Content as PageWithParent).SetParent(this);
            }
            Page thispage = this.DoPage.Content as Page;
            if (thispage is DianMuBiaoPingGu0)
            {
                if (currentStp == 1)
                {
                    (thispage as DianMuBiaoPingGu0).DianMuBiaoPingGu1_Loaded();
                }
            }
        }
    }
}